package com.lqq.session;

import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author lqq
 * @date 2019/3/4
 */
@Component
@WebFilter(urlPatterns = "/*", filterName = "authFilter")
public class SessionFilter implements Filter {
    public FilterConfig config;
    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) request;
        HttpServletResponse res=(HttpServletResponse)response;
        req = new SecurityServletRequestWrapper(req, res);
        chain.doFilter(req, res);
    }
    @Override
    public void destroy() {
        this.config=null;
    }
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        this.config=filterConfig;
    }
}